<?php
class DomainName
{
    static function getDomainName ()
    {
        return $_SERVER["SERVER_NAME"];
    }

    static function getUrlUpToDomainName ()
    {
        $protocol = 'http';
        if ($_SERVER['SERVER_PORT'] == 443 ||
         (! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
            $protocol .= 's';
            $protocol_port = $_SERVER['SERVER_PORT'];
        } else {
            $protocol_port = 80;
        }
        $host = $_SERVER['HTTP_HOST'];
        $port = $_SERVER['SERVER_PORT'];
        //$request = $_SERVER['PHP_SELF'];
        $returnValue = $protocol . '://' . $host .
         ($port == $protocol_port ? '' : ':' . $port); // . $request;
        return $returnValue;
    }
}
?>